<template>
  <div class="event-bus-sender">
    <h3>发送组件</h3>
    <input 
      v-model="message" 
      placeholder="输入消息"
    />
    <button @click="sendMessage">发送消息</button>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import EventBus from './EventBus'

const message = ref('')

const sendMessage = () => {
  if (message.value.trim()) {
    // 通过 EventBus 发送消息
    EventBus.emit('message', message.value)
    message.value = ''
  }
}
</script>

<style scoped>
.event-bus-sender {
  padding: 15px;
  background-color: #e6f3ff;
  border-radius: 5px;
}
</style>
